﻿using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using Tulde.MP3tunes.Animation;

namespace Tulde.MP3tunes
{
    public static class FrameworkElementExtensions
    {
        public static void FadeOut(this FrameworkElement element, OpacityAnimationArguments args = null) 
        {
            element.Fade(args ?? new OpacityAnimationArguments { Opacity = 0.0 });
        }


        public static void FadeIn(this FrameworkElement element, OpacityAnimationArguments args = null)
        {
            element.Fade(args ?? new OpacityAnimationArguments { Opacity = 1.0 });
        }


        public static void Fade(this FrameworkElement element, OpacityAnimationArguments args)
        {
            new OpacityAnimation(args.Opacity).Apply(element,args);
        }

        public static void CrossFade(this FrameworkElement elementToFadeOut, FrameworkElement elementToFadeIn, OpacityAnimationArguments args=null)
        {
            FadeOut(elementToFadeOut, args);
            FadeIn(elementToFadeIn, args);
        }
    }
}
